<?xml version="1.0" encoding="utf-8" ?>
<sqlMap namespace="TDepartment" xmlns="http://ibatis.apache.org/mapping" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<alias>
    <typeAlias alias="TDepartment" type="EIA.Basic.Model.TDepartment, EIA.Basic.Model" />
</alias>

<resultMaps>
<resultMap id="select-tdepartment-result" class="TDepartment">
<constructor>
    <argument argumentName="dep_id" column="dep_id"/>
    <argument argumentName="dep_name" column="dep_name"/>
    <argument argumentName="dep_des" column="dep_des"/>
    <argument argumentName="sup_id" column="sup_id"/>
    <argument argumentName="order_id" column="order_id"/>
</constructor>
<!--
    <result property="DepId" column="dep_id"/>
    <result property="DepName" column="dep_name"/>
    <result property="DepDes" column="dep_des"/>
    <result property="SupId" column="sup_id"/>
    <result property="OrderId" column="order_id"/>
-->
</resultMap>
</resultMaps>

<statements>
<sql id="sql_TDepartment_where_pk">
WHERE dep_id=#DepId#
</sql>

<sql id="sql_TDepartment_where_cv">
<dynamic prepend="WHERE">
    <isPropertyAvailable property="DepId" prepend="AND">dep_id=#DepId#</isPropertyAvailable>
    <isPropertyAvailable property="DepName" prepend="AND">dep_name LIKE concat('%', #DepName#, '%')</isPropertyAvailable>
    <isPropertyAvailable property="DepDes" prepend="AND">dep_des LIKE concat('%', #DepDes#, '%')</isPropertyAvailable>
    <isPropertyAvailable property="SupId" prepend="AND">sup_id=#SupId#</isPropertyAvailable>
    <isPropertyAvailable property="OrderId" prepend="AND">order_id=#OrderId#</isPropertyAvailable>
</dynamic>
</sql>

<sql id="sql_TDepartment_set_cols">
<dynamic prepend="SET">
    <isPropertyAvailable property="DepName" prepend=",">dep_name=#DepName#</isPropertyAvailable>
    <isPropertyAvailable property="DepDes" prepend=",">dep_des=#DepDes#</isPropertyAvailable>
    <isPropertyAvailable property="SupId" prepend=",">sup_id=#SupId#</isPropertyAvailable>
    <isPropertyAvailable property="OrderId" prepend=",">order_id=#OrderId#</isPropertyAvailable>
</dynamic>
</sql>

<select id="SelectTDepartment" parameterClass="" resultMap="TDepartment.select-tdepartment-result">
SELECT *
FROM t_department
<include refid="sql_TDepartment_where_pk"/><!--where-->
</select>

<select id="SelectTDepartment_CV" parameterClass="System.Collections.IDictionary" resultMap="TDepartment.select-tdepartment-result">
SELECT *
FROM t_department
<include refid="sql_TDepartment_where_cv"/><!--where-->
</select>

<insert id="InsertTDepartment" parameterClass="TDepartment">
<!--pre selectKey place-->
INSERT INTO t_department(
<dynamic prepend=" ">
    <isPropertyAvailable property="DepName" prepend=",">dep_name</isPropertyAvailable>
    <isPropertyAvailable property="DepDes" prepend=",">dep_des</isPropertyAvailable>
    <isPropertyAvailable property="SupId" prepend=",">sup_id</isPropertyAvailable>
    <isPropertyAvailable property="OrderId" prepend=",">order_id</isPropertyAvailable>
</dynamic>
)VALUES(
<dynamic prepend=" ">
    <isPropertyAvailable property="DepName" prepend=",">#DepName#</isPropertyAvailable>
    <isPropertyAvailable property="DepDes" prepend=",">#DepDes#</isPropertyAvailable>
    <isPropertyAvailable property="SupId" prepend=",">#SupId#</isPropertyAvailable>
    <isPropertyAvailable property="OrderId" prepend=",">#OrderId#</isPropertyAvailable>
</dynamic>
)
<selectKey resultClass="int" type="post" property="DepId" >
SELECT LAST_INSERT_ID()
</selectKey>
</insert>

<update id="UpdateTDepartment" parameterClass="System.Collections.IDictionary">
UPDATE t_department
<include refid="sql_TDepartment_set_cols"/><!--set-->
<include refid="sql_TDepartment_where_pk"/><!--where-->
</update>

<delete id="DeleteTDepartment" parameterClass="">
DELETE FROM t_department
<include refid="sql_TDepartment_where_pk"/><!--where-->
</delete>

<statement id="DeleteTDepartment_CV" parameterClass="TDepartment">
DELETE FROM t_department
<include refid="sql_TDepartment_where_cv"/><!--where-->
</statement>

<delete id="ClearTDepartment">
DELETE FROM t_department
</delete>
</statements>
</sqlMap>